package org.jsbd.boss.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.jsbd.boss.common.ResponseUtils;
import org.jsbd.boss.domian.ProvinceInfo;
import org.jsbd.boss.service.IIpService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;

@Controller
@RequestMapping("/province")
public class ProvinceController {
	public static final Logger LOGGER = LoggerFactory.getLogger(ProvinceController.class);

	@Resource
	private IIpService ipService;

	@RequestMapping(value = "getProvinceName")
	public void getProvinceName(HttpServletResponse response, Integer provinceId) {
		ResponseUtils.renderText(response, ipService.getProvinceName(provinceId));
	}

	@RequestMapping(value = "getAllProvinces")
	public void getAllProvinces(HttpServletResponse response) {
		List<ProvinceInfo> provinceList = ipService.getProvinceInfoList();
		ResponseUtils.renderJson(response, JSONObject.toJSONString(provinceList));
	}
}
